#!/bin/bash
echo "检查是否安装docker,docker-compose环境"
docker -v
if [ $? -eq  0 ]; then
 echo "检查到Docker已安装!"
else
 echo "安装docker环境..."
 curl https://gitee.com/ligson/centos7script/raw/master/crux-tools/cruxInstall.sh | bash -s init
fi
if [ ! -d "/data/docker/service/redis-cluster/" ];then
  mkdir -p /data/docker/service/redis-cluster
  else
  echo "/data/docker/service/redis-cluster 文件夹已经存在,请手动确认后删除该目录,载执行创建"
  exit
fi
if [ ! -d "/data/docker/service/" ];then
  mkdir -p /data/docker/service
fi
echo "下载redis集群安装包"
cd /data/docker/service
wget https://zwfile.yonyougov.tech/share/crux-tools/redis-cluster/redis-cluster.tar.gz --no-check-certificate
tar -zxvf redis-cluster.tar.gz
rm -rf redis-cluster.tar.gz
wget https://zwfile.yonyougov.tech/share/crux-tools/redis-cluster/redis624Image.tar.gz --no-check-certificate
docker load -i redis624Image.tar.gz
rm -rf redis624Image.tar.gz
cd redis-cluster
docker network ls | grep mynetwork
if [ $? -eq  0 ]; then
 echo "Docker网络mynetwork已存在!"
else
 echo "创建docker网络"
 docker network create mynetwork
fi
echo "创建集群"
sh $( pwd )/init.sh
